package com.example.day09_7_9_2.base;

import java.util.ArrayList;

public abstract class BasePresenter<V extends BaseView> {

    private ArrayList<BaseModel> mModels = new ArrayList<>();
    public BasePresenter(){
        initModel();
    }

    public abstract void initModel() ;

    public V view;

    public void bindView(V view) {

        this.view = view;
    }

    public void onDestory() {
        if (mModels.size() >0){
            for (int i = 0; i < mModels.size(); i++) {
                BaseModel model = mModels.get(i);
                model.onDestroy();
            }
        }
        view = null;
    }

    public void addModel(BaseModel model){
        mModels.add(model);
    }
}
